package com.pointstar.dp.modules.project.controller;

import java.util.Map;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.pointstar.dp.common.annotation.SysLog;
import com.pointstar.dp.modules.sys.controller.AbstractController;
import com.pointstar.dp.common.entity.Page;
import com.pointstar.dp.common.entity.R;
import com.pointstar.dp.modules.project.entity.ProjectRepairRecordEntity;
import com.pointstar.dp.modules.project.service.ProjectRepairRecordService;

/**
 * 报修记录表
 * @author pointstar<admin@pointstar.com>
 */
@RestController
@RequestMapping("/project/repair")
@Api(tags = "报修工单接口")
public class ProjectRepairRecordController extends AbstractController {
	
	@Autowired
	private ProjectRepairRecordService projectRepairRecordService;
	
	/**
	 * 列表
	 * @param params
	 * @return
	 */
	@RequestMapping(value = "/list", method = RequestMethod.POST)
	@ApiOperation("查询报修工单列表")
	public Page<ProjectRepairRecordEntity> list(@RequestBody Map<String, Object> params) {
		return projectRepairRecordService.listProjectRepairRecord(params);
	}
		
	/**
	 * 新增
	 * @param projectRepairRecord
	 * @return
	 */
	@SysLog("新增报修记录")
	@RequestMapping(value = "/save", method = RequestMethod.POST)
	@ApiOperation("新增报修记录表")
	public R save(@RequestBody ProjectRepairRecordEntity projectRepairRecord) {
		return projectRepairRecordService.saveProjectRepairRecord(projectRepairRecord);
	}
	
	/**
	 * 根据id查询详情
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "/info", method = RequestMethod.POST)
	@ApiOperation("根据id查询详情")
	public R getById(@RequestBody Long id) {
		return projectRepairRecordService.getProjectRepairRecordById(id);
	}
	
	/**
	 * 修改
	 * @param projectRepairRecord
	 * @return
	 */
	@SysLog("修改报修记录")
	@RequestMapping(value = "/update", method = RequestMethod.POST)
	@ApiOperation("修改报修记录表")
	public R update(@RequestBody ProjectRepairRecordEntity projectRepairRecord) {
		return projectRepairRecordService.updateProjectRepairRecord(projectRepairRecord);
	}
	
	/**
	 * 删除
	 * @param id
	 * @return
	 */
	@SysLog("删除报修记录")
	@RequestMapping(value = "/remove", method = RequestMethod.POST)
	@ApiOperation("删除报修记录表")
	public R batchRemove(@RequestBody Long[] id) {
		return projectRepairRecordService.batchRemove(id);
	}
	
}
